<?php

namespace App\Http\Controllers\Customer\Pages;

use Illuminate\Http\Request;
use App\Facades\DeviceService;
use App\Facades\WeChatService;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class DeviceController extends Controller
{

    public function down()
    {
        return view('errors.503');
    }

    public function index(Request $request)
    {
        $state = DeviceService::getState();
        if(is_null($state))
        {
            $state['deviceCode'] = deviceCode();
        }
        $host = head($request->header()['host']);
        return view('index', [
            'state' => $state,
            'host' => $host,
            ]);
    }

    public function bind(Request $request)
    {
        return view('bind')->with(wxConfig([], $request));
    }

    public function unbind()
    {
        $deviceCode = DeviceService::getDeviceCodeByUser();
        return view('unbind')->with(['deviceCode' => $deviceCode]);
    }

    public function info()
    {
        return view('deviceInfo');
    }

}
